package com.med.meddataintegrator.admin.controller;

import com.med.meddataintegrator.admin.base.response.JsonResult;
import com.med.meddataintegrator.admin.service.OptionService;
import com.med.meddataintegrator.common.pojo.dto.option.OptionQuery;
import com.med.meddataintegrator.common.pojo.dto.option.OptionSaveParam;
import com.med.meddataintegrator.common.pojo.vo.option.OptionVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/admin/option")
public class OptionController {
    @Autowired
    OptionService optionService;
    @GetMapping("select")
    public JsonResult selectOption(OptionQuery optionQuery) {
        log.debug("查询科目信息:{}", optionQuery);
        List<OptionVO> optionVOList = optionService.selectOption(optionQuery);
        return JsonResult.ok(optionVOList);
    }
    @PostMapping("save")
    public JsonResult saveOption(@RequestBody OptionSaveParam optionSaveParam){
        log.debug("保存科目信息:{}", optionSaveParam);
        optionService.saveOption(optionSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteOption(@PathVariable Integer id){
        log.debug("删除科目信息:{}", id);
        optionService.deleteOption(id);
        return JsonResult.ok();
    }
}
